using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PeaBullet : MonoBehaviour
{
    private int speed = 5;
    private int atkValuem = 20;
    private Vector3 position;
    private Zombie curContactZombie;

    private void Start()
    {
    }
    void Update()
    {
        position = transform.position;
        transform.position = new Vector3(Time.deltaTime * speed + position.x, position.y, position.z);
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == "Zombie")
        {
            collision.gameObject.TryGetComponent<Zombie>(out curContactZombie);
            curContactZombie.Hit(atkValuem);
            Destroy(gameObject);
        }

    }

    private void OnTriggerExit2D(Collider2D collision)
    {
        if (collision.tag == "Zombie")
        {
        }
    }
}
